# import os
# #1获取重命名的文件夹
# # folder_name = input('请输入文件夹的名字：')
# folder_name = r'/home/xys/datasets/ExDark/test'
# #2获取文件夹中的文件名
# file_names = os.listdir(folder_name)
# os.chdir(folder_name)
# #3对获取的名字重命名
# for name in file_names:
#       # print(name)
#       if not name.endswith('.jpg'):
#             x = name.split('.')[0]
#             print(x)
#             os.rename(name,x+'.jpg')
import os
from PIL import Image
#1获取重命名的文件夹
folder_name = r'/home/xys/datasets/ExDark/JPEGImages/'
path = r'/home/xys/datasets/ExDark/train/'
#2获取文件夹中的文件名
file_names = os.listdir(folder_name)
os.chdir(folder_name)
#3对获取的名字重命名
for name in file_names:
      # print(name)
      if name.endswith('.png'):
            x = name.split('.')[0]
            print(x)
            img = Image.open(folder_name+name)
            img = img.convert('RGB')
            img.save(path+x+'.jpg')